<%@ page import="java.util.List" %>
<%@ page import="cn.com.entity.CommentView" %><%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2020/11/11
  Time: 19:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <title>取消管理员</title>
    <style type="text/css" rel="stylesheet">
        body{
            font-family: "楷体";
            font-size: 16px;
        }
        .all{
            width: 850px;
            max-height: 550px;
            overflow: auto;
            border: 2px solid red;
            margin: 0 auto;
            padding: 50px 30px;
            box-sizing: border-box;
            margin-top: 25px;
        }
        .yheader{
            font-size: 18px;
            font-weight: 600;
            color: red;
            margin-bottom: 10px;
        }
        .allcomm{
            width: 700px;
            margin: 0 auto;

        }
        .allcomm .list{
            width: 100%;
            padding: 10px;
            margin-bottom: 20px;
            box-sizing: border-box;
            border: 2px solid #a39933;
        }
        .allcomm .head{
            height: 30px;
        }
        .allcomm .head .float{
            height: 30px;
            line-height: 30px;
        }
        .allcomm .head .fbusername{
            float: left;
        }
        .allcomm .head .fbtime{
            float: right;
        }
        .content{
            text-indent: 20px;
            line-height: 20px;
            margin: 20px 0;
            line-height: 30px;
        }
        .caozuo{
            height: 30px;
            display: flex;
            justify-content: space-around;
        }
        .caozuo .del{
            width: 60px;
            height: 30px;
            line-height: 30px;
            background: #a39933;
            color: #ffffff;
            border: none;
            cursor: pointer;
        }
        .caozuo .del:hover{
            background: red;
        }
    </style>
    <script src="/WebContent/JQuery/jquery-3.4.1.js" type="text/javascript"></script>
</head>
<body>
<article class="all">
    <div class="yheader">当前位置&nbsp;&gt;&gt;&nbsp;管理评论</div>
    <section class="allcomm">
        <%
            Object glcomm = request.getAttribute("glcomm");
            if(glcomm == null){
        %>
        <div style="text-align: center">没有数据</div>
        <%
        }else{
            List<CommentView> list = (List)glcomm;
            CommentView comm = null;
            for (int i = 0; i < list.size(); i++) {
                comm = list.get(i);
        %>
        <div class="list">
            <div class="id" style="display: none"><%=comm.getCommentId()%></div>
            <div class="head">
                <div class="float fbusername">&nbsp;&nbsp;<%=comm.getZusername()%>&nbsp;&nbsp;评论&nbsp;&nbsp;<%=comm.getBusername()%></div>
                <div class="float fbtime">评论时间：&nbsp;&nbsp;<%=comm.getPltime()%></div>
            </div>
            <div class="content">
                评论内容：<%=comm.getContent()%>
            </div>
            <div class="caozuo">
                <button type="button" class="del">删除</button>
            </div>
        </div>
        <%
                }
            }
        %>
    </section>


</article>
<script>
    $(document).ready(function () {
        $(".del").click(function () {
            if(confirm("确认删除这条帖子？")){
                var id = $.trim($(this).parent().siblings(".id").text());
                $.ajax({
                    url:"/AdminLoginServlet?type=commdel",
                    data:"id="+id,
                    type:"post",
                    dataType:"text",
                    async:false,
                    success:function (data) {
                        if(data == "1"){
                            alert("删除成功！");
                            window.location.reload();
                        }else{
                            alert("删除失败！");
                        }
                    },
                    error:function (error) {
                        alert("系统异常，稍后重试！");

                    }
                })
            }else{
                return false;
            }
        })
    })
</script>
</body>
</html>
